package _1_PIO.excel.创建;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 新建工作簿
 */
public class _1_NewWorkbook {

    @Test
    public void _2003() throws IOException {
        Workbook workbook = new HSSFWorkbook();

        try(OutputStream outputStream = new FileOutputStream("workbook.xls")){
            workbook.write(outputStream);
        }
    }

    @Test
    public void _2007() throws IOException {

        Workbook workbook = new XSSFWorkbook();

        try(OutputStream outputStream = new FileOutputStream("workbook.xlsx")){
            workbook.write(outputStream);
        }
    }

}
